﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;
using GoodMan.Infrastructure.Entities.Enum;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class OrderHistory : IAccessible<T_OrderHistory, OrderHistory>, ILogicEntity<T_OrderHistory, OrderHistory> 
    {
        public int Id { get; set; }
        public int OrderId { get; set; }
        public DateTime CreateTime { get; set; }
        public OrderStatus PreStatus { get; set; }
        public OrderStatus CurrentStatue { get; set; }
        /// <summary>
        /// 支付的时候备注什么支付方式 【货到付款、在线支付】
        /// 管理员确认收货过后可以写备注
        /// </summary>
        public string Remark { get; set; }


        protected override void Covariant(T_OrderHistory model)
        {
            if (model != null)
            {
                this.CreateTime = model.CreateTime;
                this.CurrentStatue = (OrderStatus)model.CurrentStatue;
                this.Id = model.Id;
                this.OrderId = model.OrderId;
                this.PreStatus = (OrderStatus)model.PreStatus;
                this.Remark = model.Remark;
            }
        }

        protected override T_OrderHistory Inverter(OrderHistory model)
        {
            if (model != null)
            {
                return new T_OrderHistory()
                {
                    CreateTime = model.CreateTime,
                    CurrentStatue = (int)model.CurrentStatue,
                    Id = model.Id,
                    OrderId = model.OrderId,
                    PreStatus = (int)model.PreStatus,
                    Remark = model.Remark
                };
            }
            return null;
        }

        public OrderHistory Set(T_OrderHistory dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
